---
id: get-global
title: Get Global Node
sidebar_label: Get Global
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

![Get Global Node Screenshot](./assets/get-global-node.png)

## Overview

The Get Global Node is used to retrieve a global value that is shared across all graphs and subgraphs. The ID of the global value is configured in this node.

The node can be configured to retrieve the value on demand, which means it will be read when nodes need it, rather than when this node executes. This is useful when the global value might change during the execution of the graph.

The node can also be configured to wait until the variable is available. This is useful when the global value is set by another node that might not have completed its execution when this node runs.

<Tabs
  defaultValue="inputs"
  values={[
    {label: 'Inputs', value: 'inputs'},
    {label: 'Outputs', value: 'outputs'},
    {label: 'Editor Settings', value: 'settings'},
  ]
}>

<TabItem value="inputs">

## Inputs

| Title       | Data Type | Description                                                                                                   | Default Value | Notes                                                          |
| ----------- | --------- | ------------------------------------------------------------------------------------------------------------- | ------------- | -------------------------------------------------------------- |
| Variable ID | `string`  | The ID of the global variable to retrieve. This input is only available if the "Use Input" toggle is checked. | N/A           | The input will be coerced into a string if it is not a string. |

</TabItem>

<TabItem value="outputs">

## Outputs

| Title | Data Type | Description                       | Notes                                                                                 |
| ----- | --------- | --------------------------------- | ------------------------------------------------------------------------------------- |
| Value | (any)     | The value of the global variable. | The data type of the output will be the same as the data type of the global variable. |

</TabItem>

<TabItem value="settings">

## Editor Settings

| Setting     | Description                                                                                                                       | Default Value | Use Input Toggle | Input Data Type |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- |
| Variable ID | The ID of the global variable to retrieve.                                                                                        | (required)    | Yes              | `string`        |
| Data Type   | The data type of the global variable.                                                                                             | `string`      | No               | N/A             |
| On Demand   | If enabled, the global variable will be read when nodes need it, rather than when this node executes. Cannot be used with "Wait". | True          | No               | N/A             |
| Wait        | If enabled, the node will wait until the variable is available. Cannot be used with "On Demand".                                  | False         | No               | N/A             |

</TabItem>

</Tabs>

## Example 1: Retrieve a global variable

1. Add a [Set Global Node](./set-global.mdx) to the graph. Set the variable name to `myGlobalVariable` and the value to `Hello World` using a [Text Node](./text.mdx).
2. In a separate part of the graph, add a [Delay Node](./delay.mdx) and set the delay to `1000` (1 second).
3. Create a [Text Node](./text.mdx) and set the text to `myGlobalVariable`. Pass the text into the Delay Node.
4. Create a Get Global Node, enable the input for "Variable Name", and pass the output of the Delay Node into the input. Disable the "On Demand" setting.

![Get Global Node Example 1](./assets/get-global-node-example-01.png)

## Example 2: Retrieve a global variable on-demand

1. Add a [Set Global Node](./set-global.mdx) to the graph. Set the variable name to `myGlobalVariable` and the value to `Hello World` using a [Text Node](./text.mdx).
2. Add a Get Global Node and set the variable name to `myGlobalVariable`. Enable the "On Demand" setting.
3. Add an [If Node](./if.mdx). Set the `If` input to the Set Global Node, and set the `Value` input to the Get Global Node. This will wait for both nodes to complete before running, and will pass the Get Global Node's value through to the next node.
4. Add a Text Node and connect the If Node to the Text Node.
5. Run the graph. Notice that the value of the If node is `Function<string>` because the "On-Demand" setting has been enabled, causing the value to not have resolved yet. The value is resolved in the Text Node, and "Hello World" is displayed.

![Get Global Node Example 2](./assets/get-global-node-example-02.png)

## Error Handling

The Get Global Node will error if the global variable is not found and the `Wait` setting is disabled. If the `Wait` setting is enabled, the node will wait until the variable is available.

## FAQ

**Q: What is a global variable?**

A: A global variable is a value that is shared across all graphs and subgraphs. It is set using a [Set Global Node](./set-global.mdx) and retrieved using a Get Global Node.

**Q: Can I set a global variable from a parent application?**

A: No, global variables can only be set from within the graph. Use a [Context Node](./context.mdx) instead to access global variables set by the parent application.

**Q: What happens if the global variable is not found?**

A: If the global variable is not found and the `Wait` setting is disabled, the Get Global Node will return the default value for the data type selected. For example, if the data type is set to `string`, the default value will be an empty string. If the `Wait` setting is enabled, the node will wait until the variable is available before returning the value.

## See Also

- [Set Global Node](./set-global.mdx)
- [Context Node](./context.mdx)
- [External Call Node](./external-call.mdx)
- [Raise Event Node](./raise-event.mdx)
